home *** CD-ROM | disk | FTP | other *** search
/ AmigActive 10 / AACD 10.iso / AACD / Magazine / Morphos / GCC / ppc-amigaos / include / netinet / in.h
C/C++ Source or Header  |  1997-12-08  |  17KB  |  557 lines

  1. #ifndef _NETINET_IN_H_
  2. #define _NETINET_IN_H_
  3.  
  4. #ifndef _SYS_TYPES_H_
  5. #include <sys/types.h>
  6. #endif
  7.  
  8. #ifndef _SYS_SYSCTL_H_
  9. #include <sys/sysctl.h>
  10. #endif
  11.  
  12. /*
  13.  * Constants and structures defined by the internet system,
  14.  * Per RFC 790, September 1981, and numerous additions.
  15.  */
  16.  
  17. /*
  18.  * Protocols
  19.  */
  20. #define    IPPROTO_IP        0        /* dummy for IP */
  21. #define    IPPROTO_HOPOPTS        0        /* IPv6 Hop-by-Hop options */
  22. #define    IPPROTO_ICMP        1        /* control message protocol */
  23. #define    IPPROTO_IGMP        2        /* group mgmt protocol */
  24. #define    IPPROTO_GGP        3        /* gateway^2 (deprecated) */
  25. #define IPPROTO_IPIP        4         /* IP encapsulation in IP */
  26. #define    IPPROTO_TCP        6        /* tcp */
  27. #define    IPPROTO_EGP        8        /* exterior gateway protocol */
  28. #define    IPPROTO_PUP        12        /* pup */
  29. #define    IPPROTO_UDP        17        /* user datagram protocol */
  30. #define    IPPROTO_IDP        22        /* xns idp */
  31. #define    IPPROTO_TP        29         /* tp-4 w/ class negotiation */
  32. #define IPPROTO_IPV6        41        /* IPv6 into IPv4 */
  33. #define    IPPROTO_ROUTING        43        /* IPv6 Routing header */
  34. #define    IPPROTO_FRAGMENT    44        /* IPv6 fragmentation header */
  35. #define IPPROTO_RSVP        46         /* resource reservation */
  36. #define    IPPROTO_ESP        50        /* encap security payload */
  37. #define    IPPROTO_AH        51        /* authentication header */
  38. #define IPPROTO_ICMPV6        58        /* ICMPv6/IGMPv6/NDPv6 */
  39. #define    IPPROTO_NONE        59        /* IPv6 no next header */
  40. #define    IPPROTO_DSTOPTS        60        /* IPv6 Destination options */
  41. #define    IPPROTO_EON        80        /* ISO cnlp */
  42. #define    IPPROTO_ENCAP        98        /* encapsulation header */
  43.  
  44. #define    IPPROTO_DIVERT        254        /* divert pseudo-protocol */
  45. #define    IPPROTO_RAW        255        /* raw IP packet */
  46. #define    IPPROTO_MAX        256
  47.  
  48.  
  49. /*
  50.  * Local port number conventions:
  51.  * Ports < IPPORT_RESERVED are reserved for
  52.  * privileged processes (e.g. root).
  53.  * Ports > IPPORT_USERRESERVED are reserved
  54.  * for servers, not necessarily privileged.
  55.  */
  56. #define    IPPORT_RESERVED        1024
  57. #define    IPPORT_USERRESERVED    5000
  58.  
  59. /*
  60.  * Internet address (a structure for historical reasons)
  61.  */
  62. struct in_addr {
  63.     u_long s_addr;
  64. };
  65.  
  66. #define INET_ADDRSTRLEN        16
  67.  
  68. /*
  69.  * IPv6 address (a structure for 64 bit architectures)
  70.  */
  71. struct in6_addr {
  72.     union {
  73.         u_int32_t u6_addr32[4];
  74.         u_int8_t  u6_addr8[16];
  75.     } u6_addr;
  76. };
  77. #define s6_addr32    u6_addr.u6_addr32
  78. #define s6_addr8    u6_addr.u6_addr8
  79. #define s6_addr        u6_addr.u6_addr8
  80.  
  81. #define INET6_ADDRSTRLEN    46
  82.  
  83. /*
  84.  * Definitions of bits in internet address integers.
  85.  * On subnets, the decomposition of addresses to host and net parts
  86.  * is done according to subnet mask, not the masks here.
  87.  */
  88. #define    IN_CLASSA(i)        (((long)(i) & 0x80000000) == 0)
  89. #define    IN_CLASSA_NET        0xff000000
  90. #define    IN_CLASSA_NSHIFT    24
  91. #define    IN_CLASSA_HOST        0x00ffffff
  92. #define    IN_CLASSA_MAX        128
  93.  
  94. #define    IN_CLASSB(i)        (((long)(i) & 0xc0000000) == 0x80000000)
  95. #define    IN_CLASSB_NET        0xffff0000
  96. #define    IN_CLASSB_NSHIFT    16
  97. #define    IN_CLASSB_HOST        0x0000ffff
  98. #define    IN_CLASSB_MAX        65536
  99.  
  100. #define    IN_CLASSC(i)        (((long)(i) & 0xe0000000) == 0xc0000000)
  101. #define    IN_CLASSC_NET        0xffffff00
  102. #define    IN_CLASSC_NSHIFT    8
  103. #define    IN_CLASSC_HOST        0x000000ff
  104.  
  105. #define    IN_CLASSD(i)        (((long)(i) & 0xf0000000) == 0xe0000000)
  106. #define    IN_CLASSD_NET        0xf0000000    /* These ones aren't really */
  107. #define    IN_CLASSD_NSHIFT    28        /* net and host fields, but */
  108. #define    IN_CLASSD_HOST        0x0fffffff    /* routing needn't know.    */
  109. #define    IN_MULTICAST(i)        IN_CLASSD(i)
  110.  
  111. #define    IN_EXPERIMENTAL(i)    (((long)(i) & 0xf0000000) == 0xf0000000)
  112. #define    IN_BADCLASS(i)        (((long)(i) & 0xf0000000) == 0xf0000000)
  113.  
  114. #define    INADDR_ANY        (u_long)0x00000000
  115. #define    INADDR_BROADCAST    (u_long)0xffffffff    /* must be masked */
  116. #define    INADDR_NONE        0xffffffff        /* -1 return */
  117.  
  118. #define    INADDR_UNSPEC_GROUP    (u_long)0xe0000000    /* 224.0.0.0 */
  119. #define    INADDR_ALLHOSTS_GROUP    (u_long)0xe0000001    /* 224.0.0.1 */
  120. #define    INADDR_ALLRTRS_GROUP    (u_long)0xe0000002    /* 224.0.0.2 */
  121. #define    INADDR_MAX_LOCAL_GROUP    (u_long)0xe00000ff    /* 224.0.0.255 */
  122.  
  123. #define    IN_LOOPBACKNET        127            /* official! */
  124.  
  125. #define IN6ADDR_ANY_INIT    {0, 0, 0, 0}
  126. #define IPV6ADDR_ANY_INIT    IN6ADDR_ANY_INIT    /* old name */
  127. #if BYTE_ORDER == BIG_ENDIAN
  128. #define IN6ADDR_LOOPBACK_INIT    {0, 0, 0, 1}
  129. #endif
  130. #if BYTE_ORDER == LITTLE_ENDIAN
  131. #define IN6ADDR_LOOPBACK_INIT    {0, 0, 0, 0x01000000}
  132. #endif
  133. #define IPV6ADDR_LOOPBACK_INIT    IN6ADDR_LOOPBACK_INIT    /* old name */
  134.  
  135. extern const struct in6_addr in6addr_any, in6addr_loopback;
  136.  
  137. /*
  138.  * Socket address, internet style.
  139.  */
  140. struct sockaddr_in {
  141.     u_char    sin_len;
  142.     u_char    sin_family;
  143.     u_short    sin_port;
  144.     struct    in_addr sin_addr;
  145.     char    sin_zero[8];
  146. };
  147.  
  148. /*
  149.  * IPv6 socket address
  150.  */
  151. #define    SIN6_LEN
  152.  
  153. struct sockaddr_in6 {
  154.     u_int8_t  sin6_len;
  155.     u_int8_t  sin6_family;
  156.     u_int16_t sin6_port;
  157.     u_int32_t sin6_flowinfo;
  158.     struct      in6_addr sin6_addr;
  159. };
  160.  
  161. #define IPNGVERSION    6
  162.  
  163. /*
  164.  * IPv6 routing socket pseudo-address
  165.  */
  166.  
  167. struct sockaddr_rt6 {
  168.     u_int8_t  sin6_len;
  169.     u_int8_t  sin6_family;
  170.     u_int16_t sin6_rtpad1;
  171.     u_int16_t sin6_rtpad2;
  172.     u_int16_t sin6_local;
  173.     struct      in6_addr sin6_addr;
  174. };
  175.  
  176. /*
  177.  * Definitions for flow labels.
  178.  */
  179.  
  180. #if BYTE_ORDER == BIG_ENDIAN
  181. #define IPV6_FLOWINFO_FLOWLABEL        0x00ffffff
  182. #define IPV6_FLOWINFO_PRIORITY        0x0f000000
  183. #define IPV6_FLOWINFO_PRIFLOW        0x0fffffff
  184. #define IPV6_FLOWINFO_SRFLAG        0x10000000
  185. #define IPV6_FLOWINFO_VERSION        0xf0000000
  186.  
  187. #define IPV6_PRIORITY_UNCHARACTERIZED    0x00000000
  188. #define IPV6_PRIORITY_FILLER        0x01000000
  189. #define IPV6_PRIORITY_UNATTENDED    0x02000000
  190. #define IPV6_PRIORITY_RESERVED1        0x03000000
  191. #define IPV6_PRIORITY_BULK        0x04000000
  192. #define IPV6_PRIORITY_RESERVED2        0x05000000
  193. #define IPV6_PRIORITY_INTERACTIVE    0x06000000
  194. #define IPV6_PRIORITY_CONTROL        0x07000000
  195. #define IPV6_PRIORITY_8            0x08000000
  196. #define IPV6_PRIORITY_9            0x09000000
  197. #define IPV6_PRIORITY_10        0x0a000000
  198. #define IPV6_PRIORITY_11        0x0b000000
  199. #define IPV6_PRIORITY_12        0x0c000000
  200. #define IPV6_PRIORITY_13        0x0d000000
  201. #define IPV6_PRIORITY_14        0x0e000000
  202. #define IPV6_PRIORITY_15        0x0f000000
  203.  
  204. #define IPV6_SRFLAG_STRICT        0x10000000
  205. #define IPV6_SRFLAG_LOOSE        0x00000000
  206.  
  207. #define IPV6_VERSION            0x60000000
  208.  
  209. #endif
  210. #if BYTE_ORDER == LITTLE_ENDIAN
  211. #define IPV6_FLOWINFO_FLOWLABEL        0xffffff00
  212. #define IPV6_FLOWINFO_PRIORITY        0x0000000f
  213. #define IPV6_FLOWINFO_PRIFLOW        0xffffff0f
  214. #define IPV6_FLOWINFO_SRFLAG        0x00000010
  215. #define IPV6_FLOWINFO_VERSION        0x000000f0
  216.  
  217. #define IPV6_PRIORITY_UNCHARACTERIZED    0x00000000
  218. #define IPV6_PRIORITY_FILLER        0x00000001
  219. #define IPV6_PRIORITY_UNATTENDED    0x00000002
  220. #define IPV6_PRIORITY_RESERVED1        0x00000003
  221. #define IPV6_PRIORITY_BULK        0x00000004
  222. #define IPV6_PRIORITY_RESERVED2        0x00000005
  223. #define IPV6_PRIORITY_INTERACTIVE    0x00000006
  224. #define IPV6_PRIORITY_CONTROL        0x00000007
  225. #define IPV6_PRIORITY_8            0x00000008
  226. #define IPV6_PRIORITY_9            0x00000009
  227. #define IPV6_PRIORITY_10        0x0000000a
  228. #define IPV6_PRIORITY_11        0x0000000b
  229. #define IPV6_PRIORITY_12        0x0000000c
  230. #define IPV6_PRIORITY_13        0x0000000d
  231. #define IPV6_PRIORITY_14        0x0000000e
  232. #define IPV6_PRIORITY_15        0x0000000f
  233.  
  234. #define IPV6_SRFLAG_STRICT        0x00000010
  235. #define IPV6_SRFLAG_LOOSE        0x00000000
  236.  
  237. #define IPV6_VERSION            0x00000060
  238.  
  239. #endif
  240.  
  241. #define IPV6_GET_FLOWLABEL(x)        (ntohl(x) & 0x00ffffff)
  242. #define IPV6_GET_PRIORITY(x)        ((ntohl(x) >> 24) & 0xf)
  243. #define IPV6_GET_VERSION(x)        ((ntohl(x) >> 28) & 0xf)
  244. #define IPV6_SET_FLOWLABEL(x)        (htonl(x) & IPV6_FLOWINFO_FLOWLABEL)
  245. #define IPV6_SET_PRIORITY(x)        (htonl((x & 0xf) << 24))
  246.  
  247. /*
  248.  * Definitions for IPv6 addresses.
  249.  */
  250.  
  251. #define CLR_ADDR6(a) \
  252.     { \
  253.         (a).s6_addr32[0] = 0; \
  254.         (a).s6_addr32[1] = 0; \
  255.         (a).s6_addr32[2] = 0; \
  256.         (a).s6_addr32[3] = 0; \
  257.     }
  258.  
  259. #define COPY_ADDR6(from, to) \
  260.     { \
  261.         (to).s6_addr32[0] = (from).s6_addr32[0]; \
  262.         (to).s6_addr32[1] = (from).s6_addr32[1]; \
  263.         (to).s6_addr32[2] = (from).s6_addr32[2]; \
  264.         (to).s6_addr32[3] = (from).s6_addr32[3]; \
  265.     }
  266.  
  267. #define SAME_SOCKADDR(a, b) \
  268.     (((a)->sin6_addr.s6_addr32[0] == (b)->sin6_addr.s6_addr32[0]) && \
  269.      ((a)->sin6_addr.s6_addr32[1] == (b)->sin6_addr.s6_addr32[1]) && \
  270.      ((a)->sin6_addr.s6_addr32[2] == (b)->sin6_addr.s6_addr32[2]) && \
  271.      ((a)->sin6_addr.s6_addr32[3] == (b)->sin6_addr.s6_addr32[3]))
  272.  
  273. #define SAME_ADDR6(a, b) \
  274.     (((a).s6_addr32[0] == (b).s6_addr32[0]) && \
  275.      ((a).s6_addr32[1] == (b).s6_addr32[1]) && \
  276.      ((a).s6_addr32[2] == (b).s6_addr32[2]) && \
  277.      ((a).s6_addr32[3] == (b).s6_addr32[3]))
  278.  
  279. #define IS_ANYSOCKADDR(a) \
  280.     (((a)->sin6_addr.s6_addr32[0] == 0) && \
  281.      ((a)->sin6_addr.s6_addr32[1] == 0) && \
  282.      ((a)->sin6_addr.s6_addr32[2] == 0) && \
  283.      ((a)->sin6_addr.s6_addr32[3] == 0))
  284.  
  285. #define IS_ANYADDR6(a) \
  286.     (((a).s6_addr32[0] == 0) && \
  287.      ((a).s6_addr32[1] == 0) && \
  288.      ((a).s6_addr32[2] == 0) && \
  289.      ((a).s6_addr32[3] == 0))
  290.  
  291. #define IS_COMPATSOCKADDR(a) \
  292.     (((a)->sin6_addr.s6_addr32[0] == 0) && \
  293.      ((a)->sin6_addr.s6_addr32[1] == 0) && \
  294.      ((a)->sin6_addr.s6_addr32[2] == 0) && \
  295.      ((a)->sin6_addr.s6_addr8[12] != 0))
  296.  
  297. #define IS_COMPATADDR6(a) \
  298.     (((a).s6_addr32[0] == 0) && \
  299.      ((a).s6_addr32[1] == 0) && \
  300.      ((a).s6_addr32[2] == 0) && \
  301.      ((a).s6_addr8[12] != 0))
  302.  
  303. #if BYTE_ORDER == BIG_ENDIAN
  304. #define IS_LOOPSOCKADDR(a) \
  305.     (((a)->sin6_addr.s6_addr32[0] == 0) && \
  306.      ((a)->sin6_addr.s6_addr32[1] == 0) && \
  307.      ((a)->sin6_addr.s6_addr32[2] == 0) && \
  308.      ((a)->sin6_addr.s6_addr32[3] == 1))
  309.  
  310. #define IS_LOOPADDR6(a) \
  311.     (((a).s6_addr32[0] == 0) && \
  312.      ((a).s6_addr32[1] == 0) && \
  313.      ((a).s6_addr32[2] == 0) && \
  314.      ((a).s6_addr32[3] == 1))
  315.  
  316. #define IS_IPV4SOCKADDR(a) \
  317.     (((a)->sin6_addr.s6_addr32[0] == 0) && \
  318.      ((a)->sin6_addr.s6_addr32[1] == 0) && \
  319.      ((a)->sin6_addr.s6_addr32[2] == 0x0000ffff))
  320.  
  321. #define IS_IPV4ADDR6(a) \
  322.     (((a).s6_addr32[0] == 0) && \
  323.      ((a).s6_addr32[1] == 0) && \
  324.      ((a).s6_addr32[2] == 0x0000ffff))
  325. #endif
  326. #if BYTE_ORDER == LITTLE_ENDIAN
  327. #define IS_LOOPSOCKADDR(a) \
  328.     (((a)->sin6_addr.s6_addr32[0] == 0) && \
  329.      ((a)->sin6_addr.s6_addr32[1] == 0) && \
  330.      ((a)->sin6_addr.s6_addr32[2] == 0) && \
  331.      ((a)->sin6_addr.s6_addr32[3] == 0x1000000))
  332.  
  333. #define IS_LOOPADDR6(a) \
  334.     (((a).s6_addr32[0] == 0) && \
  335.      ((a).s6_addr32[1] == 0) && \
  336.      ((a).s6_addr32[2] == 0) && \
  337.      ((a).s6_addr32[3] == 0x1000000))
  338.  
  339. #define IS_IPV4SOCKADDR(a) \
  340.     (((a)->sin6_addr.s6_addr32[0] == 0) && \
  341.      ((a)->sin6_addr.s6_addr32[1] == 0) && \
  342.      ((a)->sin6_addr.s6_addr32[2] == 0xffff0000))
  343.  
  344. #define IS_IPV4ADDR6(a) \
  345.     (((a).s6_addr32[0] == 0) && \
  346.      ((a).s6_addr32[1] == 0) && \
  347.      ((a).s6_addr32[2] == 0xffff0000))
  348. #endif
  349.  
  350. #define IS_LOCALADDR6(a)    ((a).s6_addr8[0] == 0xfe)
  351.  
  352. #define IS_LINKLADDR6(a) \
  353.     (IS_LOCALADDR6(a) && ((a).s6_addr8[1] == 0x80))
  354.  
  355. #define IS_SITELADDR6(a) \
  356.     (IS_LOCALADDR6(a) && ((a).s6_addr8[1] == 0xc0))
  357.  
  358. #define IS_MULTIADDR6(a)    ((a).s6_addr8[0] == 0xff)
  359.  
  360. #define MADDR6_FLAGS(a)        ((a).s6_addr8[1] >> 4)
  361.  
  362. #define MADDR6_FLG_WK        0    /* "well-known" multicast address */
  363. #define MADDR6_FLG_TS        1    /* "transient" multicast address */
  364.  
  365. #define MADDR6_SCOPE(a)        ((a).s6_addr8[1] & 0x0f)
  366.  
  367. #define MADDR6_SCP_NODE        0x1    /* node-local scope */
  368. #define MADDR6_SCP_LINK        0x2    /* link-local scope */
  369. #define MADDR6_SCP_SITE        0x5    /* site-local scope */
  370. #define MADDR6_SCP_ORG        0x8    /* organization-local scope */
  371. #define MADDR6_SCP_GLO        0xe    /* global scope */
  372.  
  373. #define MADDR6_ALLNODES        1    /* all-nodes groups */
  374. #define MADDR6_ALLROUTERS    2    /* all-routers groups */
  375. #define MADDR6_ALLHOSTS        3    /* all-hosts groups */
  376.  
  377. /*
  378.  * New IPv6 address macros of BSD API
  379.  */
  380.  
  381. #define IN6_IS_ADDR_UNSPECIFIED(p)    IS_ANYADDR6(*p)
  382. #define IN6_IS_ADDR_LOOPBACK(p)        IS_LOOPADDR6(*p)
  383. #define IN6_IS_ADDR_MULTICAST(p)    IS_MULTIADDR6(*p)
  384. #define IN6_IS_ADDR_LINKLOCAL(p)    IS_LINKLADDR6(*p)
  385. #define IN6_IS_ADDR_SITELOCAL(p)    IS_SITELADDR6(*p)
  386. #define IN6_IS_ADDR_V4MAPPED(p)        IS_IPV4ADDR6(*p)
  387. #define IN6_IS_ADDR_V4COMPAT(p)        IS_COMPATADDR6(*p)
  388.  
  389. #define IN6_IS_ADDR_MC_NODELOCAL(p) \
  390.     (IS_MULTIADDR6(*p) && (MADDR6_SCOPE(*p) == MADDR6_SCP_NODE))
  391. #define IN6_IS_ADDR_MC_LINKLOCAL(p) \
  392.     (IS_MULTIADDR6(*p) && (MADDR6_SCOPE(*p) == MADDR6_SCP_LINK))
  393. #define IN6_IS_ADDR_MC_SITELOCAL(p) \
  394.     (IS_MULTIADDR6(*p) && (MADDR6_SCOPE(*p) == MADDR6_SCP_SITE))
  395. #define IN6_IS_ADDR_MC_ORGLOCAL(p) \
  396.     (IS_MULTIADDR6(*p) && (MADDR6_SCOPE(*p) == MADDR6_SCP_ORG))
  397. #define IN6_IS_ADDR_MC_GLOBAL(p) \
  398.     (IS_MULTIADDR6(*p) && (MADDR6_SCOPE(*p) == MADDR6_SCP_GLO))
  399.  
  400. #define IN6_ARE_ADDR_EQUAL(pa,pb)    SAME_ADDR6(*pa,*pb)
  401.  
  402. /* My own extension (:-) */
  403.  
  404. #define IN6_ADDR_V6_TO_V4(a)    ((struct in_addr *)&(a)->s6_addr[12])
  405.  
  406. /* Grabbed from Girish's, Tom Pusateri's & Yixin Jin's code */
  407. /*
  408.  * Multicast downstream destinations
  409.  */
  410.  
  411. struct ds_in6addr {
  412.     struct    in6_addr sin6_addr;    /* downstream destination */
  413.     u_short    hoplimit;        /* min ttl required to forward */
  414.     u_short    flags;            /* attributes */
  415. };
  416.  
  417. struct sockaddr_inds {
  418.     u_char    sin_len;
  419.     u_char    sin_family;
  420.     u_short    sin_num;
  421.     char    sin_data[12];
  422. };
  423.  
  424. /*
  425.  * Structure used to describe IP options.
  426.  * Used to store options internally, to pass them to a process,
  427.  * or to restore options retrieved earlier.
  428.  * The ip_dst is used for the first-hop gateway when using a source route
  429.  * (this gets put into the header proper).
  430.  */
  431. struct ip_opts {
  432.     struct    in_addr ip_dst;        /* first hop, 0 w/o src rt */
  433.     char    ip_opts[40];        /* actually variable in size */
  434. };
  435.  
  436. /*
  437.  * Options for use with [gs]etsockopt at the IP level.
  438.  * First word of comment is data type; bool is stored in int.
  439.  */
  440. #define    IP_OPTIONS        1    /* buf/ip_opts; set/get IP options */
  441. #define    IP_HDRINCL        2    /* int; header is included with data */
  442. #define    IP_TOS            3    /* int; IP type of service and preced. */
  443. #define    IP_TTL            4    /* int; IP time to live */
  444. #define    IP_UNICAST_HOPS        IP_TTL
  445. #define    IPV6_UNICAST_HOPS    IP_TTL
  446. #define    IP_RECVOPTS        5    /* bool; receive all IP opts w/dgram */
  447. #define    IP_RECVRETOPTS        6    /* bool; receive IP opts for response */
  448. #define    IP_RECVDSTADDR        7    /* bool; receive IP dst addr w/dgram */
  449. #define    IP_RETOPTS        8    /* ip_opts; set/get IP options */
  450. #define    IP_MULTICAST_IF        9    /* u_char; set/get IP multicast i/f  */
  451. #define    IPV6_MULTICAST_IF    IP_MULTICAST_IF    /* u_int */
  452. #define    IP_MULTICAST_TTL    10   /* u_char; set/get IP multicast ttl */
  453. #define IP_MULTICAST_HOPS    IP_MULTICAST_TTL
  454. #define IPV6_MULTICAST_HOPS    IP_MULTICAST_TTL    /* int */
  455. #define    IP_MULTICAST_LOOP    11   /* u_char; set/get IP multicast loopback */
  456. #define    IPV6_MULTICAST_LOOP    IP_MULTICAST_LOOP    /* u_int */
  457. #define    IP_ADD_MEMBERSHIP    12   /* ip_mreq; add an IP group membership */
  458. #define    IPV6_ADD_MEMBERSHIP    IP_ADD_MEMBERSHIP
  459. #define    IP_DROP_MEMBERSHIP    13   /* ip_mreq; drop an IP group membership */
  460. #define    IPV6_DROP_MEMBERSHIP    IP_DROP_MEMBERSHIP
  461. #define IP_MULTICAST_VIF    14   /* set/get IP mcast virt. iface */
  462. #define IP_RSVP_ON        15   /* enable RSVP in kernel */
  463. #define IP_RSVP_OFF        16   /* disable RSVP in kernel */
  464. #define IP_RSVP_VIF_ON        17   /* set RSVP per-vif socket */
  465. #define IP_RSVP_VIF_OFF        18   /* unset RSVP per-vif socket */
  466.  
  467. /*
  468.  * Defaults and limits for options
  469.  */
  470. #define    IP_DEFAULT_MULTICAST_TTL  1    /* normally limit m'casts to 1 hop  */
  471. #define    IP_DEFAULT_MULTICAST_LOOP 1    /* normally hear sends if a member  */
  472. #define    IP_MAX_MEMBERSHIPS    20    /* per socket */
  473.  
  474. /*
  475.  * Argument structure for IP_ADD_MEMBERSHIP and IP_DROP_MEMBERSHIP.
  476.  */
  477. struct ip_mreq {
  478.     struct    in_addr imr_multiaddr;    /* IP multicast address of group */
  479.     struct    in_addr imr_interface;    /* local IP address of interface */
  480. };
  481. struct ipv6_mreq {
  482.     struct in6_addr ipv6mr_multiaddr; /* IPv6 multicast address of group */
  483.     unsigned long ipv6mr_interface;    /* local IPv6 address of interface */
  484. };
  485.  
  486. /*
  487.  * packet information
  488.  */
  489. struct in6_pktinfo {
  490.     struct in6_addr ipi6_addr;    /* src/dst IPv6 address */
  491.     long        ipi6_ifindex;    /* send/recv interface index */
  492. };
  493.  
  494. /*
  495.  * Definitions for inet sysctl operations.
  496.  *
  497.  * Third level is protocol number.
  498.  * Fourth level is desired variable within that protocol.
  499.  */
  500. #define    IPPROTO_MAXID    (IPPROTO_IDP + 1)    /* don't list to IPPROTO_MAX */
  501.  
  502. #define    CTL_IPPROTO_NAMES { \
  503.     { "ip", CTLTYPE_NODE }, \
  504.     { "icmp", CTLTYPE_NODE }, \
  505.     { "igmp", CTLTYPE_NODE }, \
  506.     { "ggp", CTLTYPE_NODE }, \
  507.     { 0, 0 }, \
  508.     { 0, 0 }, \
  509.     { "tcp", CTLTYPE_NODE }, \
  510.     { 0, 0 }, \
  511.     { "egp", CTLTYPE_NODE }, \
  512.     { 0, 0 }, \
  513.     { 0, 0 }, \
  514.     { 0, 0 }, \
  515.     { "pup", CTLTYPE_NODE }, \
  516.     { 0, 0 }, \
  517.     { 0, 0 }, \
  518.     { 0, 0 }, \
  519.     { 0, 0 }, \
  520.     { "udp", CTLTYPE_NODE }, \
  521.     { 0, 0 }, \
  522.     { 0, 0 }, \
  523.     { 0, 0 }, \
  524.     { 0, 0 }, \
  525.     { "idp", CTLTYPE_NODE }, \
  526. }
  527.  
  528. /*
  529.  * Names for IP sysctl objects
  530.  */
  531. #define    IPCTL_FORWARDING    1    /* act as router */
  532. #define    IPCTL_SENDREDIRECTS    2    /* may send redirects when forwarding */
  533. #define    IPCTL_DEFTTL        3    /* default TTL */
  534. #ifdef notyet
  535. #define    IPCTL_DEFMTU        4    /* default MTU */
  536. #endif
  537. #define IPCTL_RTEXPIRE        5    /* cloned route expiration time */
  538. #define IPCTL_RTMINEXPIRE    6    /* min value for expiration time */
  539. #define IPCTL_RTMAXCACHE    7    /* trigger level for dynamic expire */
  540. #define    IPCTL_SOURCEROUTE    8    /* may perform source routes */
  541. #define    IPCTL_MAXID        9
  542.  
  543. #define    IPCTL_NAMES { \
  544.     { 0, 0 }, \
  545.     { "forwarding", CTLTYPE_INT }, \
  546.     { "redirect", CTLTYPE_INT }, \
  547.     { "ttl", CTLTYPE_INT }, \
  548.     { "mtu", CTLTYPE_INT }, \
  549.     { "rtexpire", CTLTYPE_INT }, \
  550.     { "rtminexpire", CTLTYPE_INT }, \
  551.     { "rtmaxcache", CTLTYPE_INT }, \
  552.     { "sourceroute", CTLTYPE_INT }, \
  553. }
  554.  
  555. #endif
  556.  
  557.